import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import dayjs from 'dayjs';
const headerMap = new Map();
headerMap.set(1, '优品直供');
headerMap.set(2, '健康管理');
headerMap.set(3, '居家养老');
headerMap.set(4, '我的会员');
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '订单编号',
    align: 'center',
    dataIndex: 'orderNumber',
  },
  {
    title: '所属大类',
    align: 'center',
    dataIndex: 'header',
    customRender: ({ record: { header } }) => headerMap.get(header),
  },
  {
    title: '下单用户',
    align: 'center',
    dataIndex: 'userId_dictText',
  },
  {
    title: '订单总价',
    align: 'center',
    dataIndex: 'totalPrice',
  },
  // {
  //   title: '优惠金额',
  //   align: 'center',
  //   dataIndex: 'discountAmount',
  // },
  {
    title: '应付金额',
    align: 'center',
    dataIndex: 'amountPayable',
  },
  {
    title: '运费',
    align: 'center',
    dataIndex: 'shippingFee',
  },
  // {
  //   title: '返积分',
  //   align: 'center',
  //   dataIndex: 'points',
  // },
  {
    title: '订单状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  // {
  //   title: '收货地址ID',
  //   align: 'center',
  //   dataIndex: 'addressId',
  // },
  // {
  //   title: '备注',
  //   align: 'center',
  //   dataIndex: 'remarks',
  // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderNumber',
    label: '订单编号',
    component: 'Input',
  },
  {
    label: '订单状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'order_status',
    },
  },
  {
    field: 'timeRange',
    label: '下单时间',
    component: 'RangePicker',
    // defaultValue: [dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss'), dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')],
    componentProps: {
      //是否显示时间
      showTime: true,
      //日期格式化
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      //范围文本描述用集合
      placeholder: ['请选择开始日期时间', '请选择结束日期时间'],
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '订单编号',
    field: 'orderNumber',
    component: 'Input',
  },
  {
    label: '订单总价',
    field: 'totalPrice',
    component: 'InputNumber',
  },
  {
    label: '优惠金额',
    field: 'discountAmount',
    component: 'InputNumber',
  },
  {
    label: '应付金额',
    field: 'amountPayable',
    component: 'InputNumber',
  },
  {
    label: '运费',
    field: 'shippingFee',
    component: 'InputNumber',
  },
  {
    label: '返积分',
    field: 'points',
    component: 'InputNumber',
  },
  {
    label: '订单状态',
    field: 'status',
    component: 'InputNumber',
  },
  {
    label: '下单用户',
    field: 'userId',
    component: 'Input',
  },
  {
    label: '收货地址ID',
    field: 'addressId',
    component: 'Input',
  },
  {
    label: '所属大类',
    field: 'header',
    component: 'Select',
    componentProps: {
      options: [
        { label: '优品直供', value: 1 },
        { label: '健康管理', value: 2 },
        { label: '居家养老', value: 3 },
        { label: '我的会员', value: 4 },
      ],
    },
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  orderNumber: { title: '订单编号', order: 0, view: 'text', type: 'string' },
  totalPrice: { title: '订单总价', order: 1, view: 'number', type: 'number' },
  discountAmount: { title: '优惠金额', order: 2, view: 'number', type: 'number' },
  amountPayable: { title: '应付金额', order: 3, view: 'number', type: 'number' },
  shippingFee: { title: '运费', order: 4, view: 'number', type: 'number' },
  points: { title: '返积分', order: 5, view: 'number', type: 'number' },
  status: { title: '订单状态', order: 6, view: 'number', type: 'number' },
  userId: { title: '下单用户', order: 7, view: 'text', type: 'string' },
  addressId: { title: '收货地址ID', order: 8, view: 'text', type: 'string' },
  header: { title: '所属大类（优品直供1，健康管理2，居家养老3，我的会员4）', order: 9, view: 'number', type: 'number' },
  remarks: { title: '备注', order: 10, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
